import fetch from '@/utils/request';

const API_PAYMENT_URL = '/api/user/payment';
/**
 * 支付API对象
 * @module PaymentApi
 */
const PaymentApi = {
	/**
	 * @function methods
	 * @description 查询订单支付方式
	 * @param  {String} platform 平台类型
	 */
	methods: (platform) => fetch.request({
		url: `${API_PAYMENT_URL}/methods`,
		method: 'POST',
		data: {
			platform,
		}
	}),
	/**
	 * @function prepare
	 * @description 发起支付
	 * @param  {String} paymentMethodId 支付方式Id
	 * @param  {String} orderId 订单Id
	 * @param  {String} appId AppId
	 * @param  {String} paymentMethodName 支付方式名称
	 * @param  {String} platform 平台
	 */
	prepare: (paymentMethodId, orderId, appId, paymentMethodName, platform) => fetch.request({
		url: `${API_PAYMENT_URL}/prepare`,
		method: 'POST',
		data: {
			paymentMethodId,
			orderId,
			appId,
			paymentMethodName,
			platform
		}
	}),
	/**
	 * @function check
	 * @description 支付校检
	 * @param  {String} paymentId 支付Id
	 */
	check: (paymentId) => fetch.request({
		url: `${API_PAYMENT_URL}/check`,
		method: 'POST',
		data: {
			paymentId
		}
	}),
};
export default PaymentApi;